package com.workcenter.controls;

import java.util.ArrayList;
import java.util.List;

import com.workcenter.app.R;
import com.workcenter.entity.model.ECustomerInfo;
import com.workcenter.entity.model.ERepairsInfo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class AdpLV_CustomerInfo extends BaseAdapter
{
   private ArrayList<ECustomerInfo> list;
   private Context mContext;
   private LayoutInflater mInflater;

   public AdpLV_CustomerInfo()
   {

   }

   public AdpLV_CustomerInfo(ArrayList<ECustomerInfo> _list, Context _context)
   {
	  list = _list;
	  mContext = _context;
	  mInflater = LayoutInflater.from(_context);
   }

   @Override
   public int getCount()
   {
	  return list.size();
   }

   @Override
   public Object getItem(int position)
   {
	  return list.get(position);
   }

   @Override
   public long getItemId(int position)
   {
	  return 0;
   }

   @Override
   public View getView(int position, View convertView, ViewGroup parent)
   {
	  try
	  {
		 convertView = mInflater.inflate(R.layout.customerlist_item, null);
		 TextView txtCustomer = (TextView) convertView.findViewById(R.id.txtCustomerName_customerlist_item);
		 TextView txtInstrument = (TextView) convertView.findViewById(R.id.txtInstrument_customerlist_item);
		 TextView txtInstrumentId = (TextView) convertView.findViewById(R.id.txtInstrumentId_customerlist_item);
		 TextView txtInstrumentState = (TextView) convertView.findViewById(R.id.txtInstrumentState_customerlist_item);
		 TextView txtContact = (TextView) convertView.findViewById(R.id.txtContact_customerlist_item);
		 TextView txtPhone = (TextView) convertView.findViewById(R.id.txtPhone_customerlist_item);
		 TextView txtRoomName = (TextView) convertView.findViewById(R.id.txtRoomName_customerlist_item);
		 TextView txtArea=(TextView)convertView.findViewById(R.id.txtArea_customerlist_item);
		 txtCustomer.setText(list.get(position).getCustomerName());
		 txtInstrument.setText(list.get(position).getInstrument());
		 txtInstrumentId.setText(list.get(position).getInstrumentID());
		 txtInstrumentState.setText(list.get(position).getInstrumentState());
		 txtContact.setText(list.get(position).getContact());
		 txtPhone.setText(list.get(position).getPhone());
		 txtRoomName.setText(list.get(position).getRoomName());
		 txtArea.setText(list.get(position).getArea());
		 return convertView;
	  }
	  catch (Exception e)
	  {

	  }
	  return new View(mContext);

   }
}
